home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Scissors.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  2.6 KB  |  86 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define BlockSize 10
  15. #define CorrectTime 3
  16.  
  17. void Scissors(GrafPtr);
  18.  
  19. /* A region in two parts, starting at the top of the left and right sides and
  20.    moving down the sides and together towards the middle of the bottom side. */
  21.    
  22. void Scissors(GrafPtr sourceGrafPtr)
  23. {
  24.     RgnHandle    curregion;
  25.     Rect        source,dest;
  26.     int            cx,gap,lastx,lasty;
  27.     
  28.     cx = MAIN_WINDOW_WIDTH / 2;
  29.  
  30.     curregion=NewRgn();
  31.     source.top=source.left=0;
  32.     source.bottom=MAIN_WINDOW_HEIGHT;
  33.     source.right=MAIN_WINDOW_WIDTH;
  34.     
  35.     gap=BlockSize;
  36.     lasty=0;
  37.     do
  38.     {
  39.         StartTiming();
  40.         SetEmptyRgn(curregion);
  41.         MoveTo(cx,0);
  42.         OpenRgn();
  43.             LineTo(MAIN_WINDOW_WIDTH,lasty);   /* get the right half */
  44.             LineTo(MAIN_WINDOW_WIDTH,gap);
  45.             LineTo(cx,0);
  46.             LineTo(0,lasty);                   /* get the left half */
  47.             LineTo(0,gap);
  48.             LineTo(cx,0);
  49.         CloseRgn(curregion);
  50.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  51.             &source, &source, 0, curregion);
  52.         lasty=gap;
  53.         gap+=BlockSize;
  54.         TimeCorrection(CorrectTime);
  55.     }
  56.     while (gap<MAIN_WINDOW_HEIGHT+BlockSize);
  57.     
  58.     lastx=MAIN_WINDOW_WIDTH;
  59.     gap=MAIN_WINDOW_WIDTH-BlockSize;
  60.     do
  61.     {
  62.         StartTiming();
  63.         SetEmptyRgn(curregion);
  64.         MoveTo(cx,0);
  65.         OpenRgn();
  66.             LineTo(lastx,MAIN_WINDOW_HEIGHT);    /* get the right half on bottom side */
  67.             LineTo(gap,MAIN_WINDOW_HEIGHT);
  68.             LineTo(cx,0);
  69.             LineTo(MAIN_WINDOW_WIDTH-lastx,MAIN_WINDOW_HEIGHT); /* left 1/2 on bottom */
  70.             LineTo(MAIN_WINDOW_WIDTH-gap,MAIN_WINDOW_HEIGHT);
  71.             LineTo(cx,0);
  72.         CloseRgn(curregion);
  73.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  74.             &source, &source, 0, curregion);
  75.         lastx=gap;
  76.         gap-=BlockSize;
  77.         TimeCorrection(CorrectTime);
  78.     }
  79.     while (gap>MAIN_WINDOW_WIDTH/2);
  80.     
  81.     CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  82.         &source, &source, 0, 0L);   /* if we missed any bits */
  83.     
  84.     DisposeRgn(curregion);
  85. }
  86.